package main

import (
	"os"
	"runtime"
	"syscall"
	"websocket/test1"
	"websocket/test2"
	"github.com/gin-gonic/gin"
)

func main() {
	t1 := test1.New()
	t2 := test2.New()

	runtime.GOMAXPROCS(runtime.NumCPU())
	gin.SetMode(gin.ReleaseMode)
	r := gin.Default()
	r.GET("/videochat/ws/:userId", func(c *gin.Context) {
		t1.Handler(c.Writer, c.Request, c)
	})
	go func() {
		r.Run("0.0.0.0:8032")
	}()

	runtime.GOMAXPROCS(runtime.NumCPU())
	gin.SetMode(gin.ReleaseMode)
	r2 := gin.Default()
	r2.GET("/videochat/ws/:filename/:userId", func(c *gin.Context) {
		t2.Handler(c.Writer, c.Request, c)
	})
	go func() {
		r2.Run("0.0.0.0:8031")
	}()

	c := make(chan os.Signal, 1)
	for {
		s := <-c
		switch s {
		case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
			return
		case syscall.SIGHUP:

		default:
			return
		}
	}
}
